<template>
    <div>

        <div>
            <div v-for="(cate, index) in catelist" :key="index" v-if="cate.price">
                申请人：{{cate.staff}}<br>
                采购原因：{{cate.cause}}<br>
                价格：{{cate.price}}<br>
                
                <div v-for="(a1, index) in a1_list" :key="index">
                    审批人{{index+1}}：{{a1.username}}
                </div>

                <a-button type="primary" @click="consent(cate.wid)">同意</a-button>

                <a-button @click="refuse(cate.wid)">拒绝</a-button>

                <br><br>
            </div>


            <div v-for="(cate, index) in catelist" :key="index" v-if="cate.start_time">
                申请人：{{cate.staff}}<br>
                请假原因：{{cate.cause}}<br>
                开始时间：{{cate.start_time}}<br>
                结束时间：{{cate.end_time}}<br>

                <div v-for="(a, index) in a_list" :key="index">
                    审批人{{index+1}}：{{a.username}}<br>
                </div>

                <a-button type="primary" @click="consent1(cate.wid)">同意</a-button>

                <a-button @click="refuse1(cate.wid)">拒绝</a-button>

            </div>

        </div>

    </div>
</template>

<script>
export default {
    data() {
        return {
            catelist:[],
            a_list:[],
            a1_list:[],
            pid:2,
            pid1:3,
            uid:localStorage.getItem('uid'),
            count1:''
        }
    },

    mounted:function(){

        this.axios.get("http://localhost:8000/workorderinfo/",).then(res=>{
            this.catelist = res.data
            console.log(res.data)
        })

        this.get_approver()
        this.get_approver1()
        this.message()
    },

    methods:{

        // 消息提示
        message(){
            this.axios.put("http://localhost:8000/message/").then(res=>{
                console.log(res.data)
            })
        },

        consent(wid){
            this.axios.post("http://localhost:8000/workalist/", this.qs.stringify({'aid':this.uid,'wid':wid})).then(res=>{
                console.log(res.data)
            })
        },

        refuse(wid){
            this.axios.post("http://localhost:8000/refuse/", this.qs.stringify({'aid':this.uid,'wid':wid})).then(res=>{
                console.log(res.data)
            })
        },

        consent1(wid){
            this.axios.post("http://localhost:8000/workalist/", this.qs.stringify({'aid':this.uid,'wid':wid})).then(res=>{
                console.log(res.data)
            })
        },

        refuse1(wid){
            this.axios.post("http://localhost:8000/refuse/", this.qs.stringify({'aid':this.uid,'wid':wid})).then(res=>{
                console.log(res.data)
            })
        },

        get_approver(){
            this.axios.get("http://localhost:8000/getapprover/",{params:{'pid':this.pid}}).then(res=>{
                this.a_list = res.data
            })
        },

        get_approver1(){
            this.axios.get("http://localhost:8000/getapprover/",{params:{'pid':this.pid1}}).then(res=>{
                this.a1_list = res.data
            })
        },
    }

}
</script>

<style>

</style>